package hot;

import java.util.ArrayList;
import java.util.List;

public class qiba {
//    https://leetcode.cn/problems/subsets/

    class Solution {
        List<List<Integer>> ret=new ArrayList<>();
        List<Integer> path=new ArrayList<>();
        public List<List<Integer>> subsets(int[] nums) {
            dfs(nums,0);
            return ret;
        }
        public void dfs(int[] nums,int i){
            if(i==nums.length){
                ret.add(new ArrayList(path));
                //这里不用恢复现场
                return;
            }
            //如果选了
            path.add(nums[i]);
            dfs(nums,i+1);
            //回溯 恢复现场
            path.remove(path.size()-1);

            //如果不选
            dfs(nums,i+1);


        }
    }
}
